// Includes
#include "TextureLoaders.h"

#include <SDL/SDL_image.h>		// SDL_image library header

namespace EraAstral
{
	// Load texture from bitmap file
	Texture *LoadBMP(const char *fileName)
	{
		// Store image data in SDL surface
		SDL_Surface *surface = SDL_LoadBMP(fileName);
		
		if (surface == NULL)
			return NULL;
			
		// Create texture from SDL surface
		Texture *retTex = new Texture(surface);
		// Free SDL surface
		SDL_FreeSurface(surface);
		return retTex;
	}
	
	// Loads a texture from a JPEG file
	Texture *LoadJPG(const char *fileName)
	{
		// Store image data in SDL surface
		SDL_Surface *surface = IMG_Load(fileName);
		
		if (surface == NULL)
			return NULL;
			
		// Create texture from SDL surface
		Texture *retTex = new Texture(surface);
		// Free SDL surface
		SDL_FreeSurface(surface);
		return retTex;
	}
	
	// Loads a texture from a PNG file
	Texture *LoadPNG(const char *fileName)
	{
		// Store image data in SDL surface
		SDL_Surface *surface = IMG_Load(fileName);
		
		if (surface == NULL)
			return NULL;
			
		// Create texture from SDL surface
		Texture *retTex = new Texture(surface);
		// Free SDL surface
		SDL_FreeSurface(surface);
		return retTex;
	}
}
